require 'rubygems'
require 'json/pure'

module GoogleSearch
  class Results
    def initialize(json_search_results)
      @json_search_results = json_search_results
    end

    def self.parse(results)
      Results.new JSON.parse(results)
    end

    def each
      @json_search_results['responseData']['results'].each do |result|
        yield GoogleSearch::Result.parse result.to_json
      end
    end
  end
end
